﻿Public Class SelectionContacts
    Inherits OpenDelibPage

    Protected Overrides Sub OnInit(e As EventArgs)
        MyBase.OnInit(e)

        Dim appPath As String = Request.ApplicationPath
        If appPath = "/" Then
            appPath = ""
        End If

        AddCss(Me, appPath & "/Css/Fiche.css")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Odyssee.WebControles.JQPopupPanel.SetCancelScript(Me.btnAnnuler, False)

        Dim autoriserSelectionMultiple As Boolean = True
        If Request.QueryString("multiple") <> "" AndAlso IsNumeric(Request.QueryString("multiple")) Then autoriserSelectionMultiple = (CInt(Request.QueryString("multiple")) = 1)

        Me.ctrlSelection.Initialiser(True, False, autoriserSelectionMultiple)
    End Sub

    Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
        Dim contacts As List(Of ServiceContacts.Contact) = Me.ctrlSelection.ResultatsSelectionnes
        If contacts.Count <= 0 Then
            Me.NotifyErreur("Vous devez sélectionner un contact !")
            Return
        End If

        Dim retour As String = ""
        For Each contact As ServiceContacts.Contact In contacts
            If retour <> "" Then retour &= "¤"
            retour &= contact.Cle.ToString
        Next
        ScriptManager.RegisterStartupScript(Me, Me.GetType, "FermeturePopup", Odyssee.WebControles.JQPopupPanel.CreateOKScript(retour), True)
    End Sub

End Class